<header class="auth-setting-header">
    <h1>市场管理</h1>
</header> 
<div class="tools-row clearfix">

        </div>
        
        <div class="tools-row clearfix">
            <div class="col-xs-8">
                <form class="form-inline pull-left" ng-if='areaSearch'>
                    <div class="form-group">
                        <label for="exampleInputName2">*地区列表</label>
                        <select class="form-control" name="" id="">
                            <option value="所有">所有</option>
                        </select>
                        <select class="form-control" name="" id="">
                            <option value="所有">所有</option>
                        </select>
                        <select class="form-control" name="" id="">
                            <option value="所有">所有</option>
                        </select>
                    </div>
                </form>
            </div>
            
        </div>
        <div class="tools-row clearfix">
            <div class="col-xs-4">
                <a data-ng-click="marketCtrl.addMarket()" class="pull-left btn btn-success">添加</a>
                <a class="ml-sm pull-left btn btn-danger" ng-show='marketCtrl.toggleCheckbox||marketCtrl.showOperationButton' data-ng-click="marketCtrl.deleteAll()">删除</a>
            </div>
<!--             <div class="col-xs-offset-4 col-xs-4">
                <form class="form-inline pull-right">
                    <div class="form-group">
                        <input type="text" data-ng-model='marketFilter' class="form-control" placeholder="产品号/型号">
                    </div>
                </form>
            </div> -->
        </div>
        <div class="table-padding">
        <table class="table table-bordered table-condensed">
            <tr >
              <td style="width:2%"  data-ng-click="marketCtrl.toggleAllCheckbox()"><checkbox  ng-model="marketCtrl.toggleCheckbox"></checkbox></td>
              <td style="width:15%">市场名称</td>
              <td style="width:10%">省</td>
              <td style="width:10%">城市</td>
              <td style="width:10%">地区</td>
              <td style="width:23%">详细地址</td>
              <td style="width:15%">联系方式</td>
              <td style="width:15%">操作</td>
            </tr>
            <tr ng-repeat="market in marketCtrl.markets">
              <td data-ng-click="marketCtrl.showOperation(market.$selected)">
                  <checkbox ng-model="market.$selected"></checkbox> 
              </td>
              <td>
                <span editable-text="market.market_name" onbeforesave='marketCtrl.checkData($data)' e-name="name" e-form="rowform" onbeforesave="checkName($data, market.id)" e-required>
                  {{ market.market_name || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-select="market.province_id" onbeforesave='marketCtrl.checkData($data)' onshow='marketCtrl.GetProvinceList(market)' e-ng-options='g.id as g.name for g in market.provinceList' e-ng-change='marketCtrl.GetCityList(market,$data)' e-name="province_id" e-form="rowform">
                  {{ marketCtrl.showAreaName(market,0) }}
                </span>
              </td>
              <td>
                <span editable-select="market.city_id" onbeforesave='marketCtrl.checkData($data)' e-ng-options='g.id as g.name for g in market.cityList' e-ng-change='marketCtrl.GetCountyList(market,$data)' e-name="city_id" e-form="rowform">
                  {{ marketCtrl.showAreaName(market,1) }}
                </span>
              </td>
              <td>
                <span editable-select="market.county_id" onbeforesave='marketCtrl.checkData($data)' e-ng-options='g.id as g.name for g in market.countyList' e-name="county_id" e-form="rowform">
                  {{ marketCtrl.showAreaName(market,2) }}
                </span>
              </td>
              <td>
                <span editable-text="market.detail_address" onbeforesave='marketCtrl.checkData($data)' e-name="detail_address" e-form="rowform" e-required>
                  {{ market.detail_address || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-text="market.contact" onbeforesave='marketCtrl.checkPhon($data)' e-name="contact" e-form="rowform" onbeforesave="marketCtrl.checkPhone($data, market.id)" e-required>
                  {{ market.contact || '暂无' }}
                </span>
              </td>
              <td style="white-space: nowrap">
                <form editable-form name="rowform" shown="marketCtrl.inserted == market" onbeforesave="marketCtrl.saveMarket($data, market.market_id)" ng-show="rowform.$visible" class="form-as form-inline">
                  <button type="submit" ng-disabled="rowform.$waiting" class="btn btn-info">
                    保存
                  </button>
                  <a ng-disabled="rowform.$waiting" ng-click="marketCtrl.cancel(rowform,marketCtrl.inserted == market)" class="btn btn-default">
                    取消
                  </a>
                </form>
                <div class="buttons" ng-show="!rowform.$visible">
                  <a class="btn btn-info" ng-click="rowform.$show()"><em class="icon-pencil"></em></a>
                  <a class="btn btn-danger" ng-click="marketCtrl.removeMarket($index,market)"><em class="icon-trash"></em></a>
                </div>  
              </td>
            </tr>
          </table>
          <p class="text-center" data-ng-show="marketCtrl.markets.length<1">暂无内容</p>

          <uib-pagination ng-if='marketCtrl.pagination.total_item' ng-change="marketCtrl.paginationChange()" total-items="marketCtrl.pagination.total_item" items-per-page="marketCtrl.pagination.page_size" ng-model="marketCtrl.pagination.page_no" max-size="marketCtrl.pagination.max_size"  class="pagination-sm" boundary-link-numbers="true" rotate="false" next-text="下一页" previous-text="上一页"></uib-pagination>

        </div>

